<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="//cdn.bootcss.com/sockjs-client/1.1.1/sockjs.min.js"></script>
    <script src="//cdn.bootcss.com/stomp.js/2.3.3/stomp.min.js"></script>
    <script src="//cdn.bootcss.com/jquery/2.1.2/jquery.min.js"></script>
</head>
<body>

<input id="connect" type="button" value="连接" >
<input id="sendmsg" type="button" value="发送信息" >

<script>
$(function () {

    var socket = null;
    var stompClient = null;
    function connectSocket() {
        socket = new SockJS('/socket');
        stompClient = Stomp.over(socket);
        stompClient.connect({}, function (frame) {
            console.info(frame);
        });
    }

    function sendName() {
        stompClient.send("/app/all", {}, "huangqiwei");
    }

    $("#connect").on("click",function () {
        connectSocket();
    });

    $("#sendmsg").on("click",function () {
        sendName();
    });


})

</script>

</body>
</html>